﻿
using Sunny.UI;

namespace DABLL
{
    public class Config
    {
        //配置文件路径
        static String configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.ini");

        //ini文件操作类
        private static IniFile ini = new IniFile(configPath);

        private static string BroadKey = "BROAD";

        private static string TestKey = "TEST";

        /// <summary> 串口地址
        /// 
        /// </summary>
        public static string PortAddress
        {
            get
            {
                return ini.ReadString("VOICE", "Port", "COM4");
            }
            set
            {
                ini.Write("VOICE", "Port", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 波特率
        /// 
        /// </summary>
        public static int Baudrate
        {
            get
            {
                return ini.ReadInt("VOICE", "Baudrate", 9600);
            }
            set
            {
                ini.Write("VOICE", "Baudrate", value);
                ini.UpdateFile();
            }
        }

        /// <summary>
        /// 启动程序时播报
        /// </summary>
        public static bool RunBroad
        {
            get
            {
                return ini.ReadBool(BroadKey, "RunBroad", false);
            }
            set
            {
                ini.Write(BroadKey, "RunBroad", value);
                ini.UpdateFile();
            }
        }

        /// <summary>
        /// 启动播报内容
        /// </summary>
        public static string RunBroadMessage
        {
            get
            {
                return ini.ReadString(BroadKey, "RunBroadMessage", "开机请建立工程");
            }
            set
            {
                ini.Write(BroadKey, "RunBroadMessage", value);
                ini.UpdateFile();
            }
        }

        /// <summary>
        /// 开始采集时播报
        /// </summary>
        public static bool StartBroad
        {
            get
            {
                return ini.ReadBool(BroadKey, "StartBroad", false);
            }
            set
            {
                ini.Write(BroadKey, "StartBroad", value);
                ini.UpdateFile();
            }
        }

        /// <summary>
        /// 开始采集时播报内容
        /// </summary>
        public static string StartBroadMessage
        {
            get
            {
                return ini.ReadString(BroadKey, "StartBroadMessage", "开始采集请注意安全");
            }
            set
            {
                ini.Write(BroadKey, "StartBroadMessage", value);
                ini.UpdateFile();
            }
        }

        /// <summary>
        /// 播报错误
        /// </summary>
        public static bool ErrorBroad
        {
            get
            {
                return ini.ReadBool(BroadKey, "ErrorBroad", false);
            }
            set
            {
                ini.Write(BroadKey, "ErrorBroad", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 播报错误间隔
        /// 
        /// </summary>
        public static int ErrorBroadInterval
        {
            get
            {
                return ini.ReadInt(BroadKey, "ErrorBroadInterval", 30);
            }
            set
            {
                ini.Write(BroadKey, "ErrorBroadInterval", value);
                ini.UpdateFile();
            }
        }

        /// <summary>
        /// 播报试压阶段
        /// </summary>
        public static bool StageBroad
        {
            get
            {
                return ini.ReadBool(BroadKey, "StageBroad", true);
            }
            set
            {
                ini.Write(BroadKey, "StageBroad", value);
                ini.UpdateFile();
            }
        }

        /// <summary> 取样点数量
        /// 
        /// </summary>
        public static int PointCount
        {
            get
            {
                return ini.ReadInt(TestKey, "Count", 10);
            }
            set
            {
                ini.Write(TestKey, "Count", value);
                ini.UpdateFile();
            }
        }
    }
}
